//
//  EditContentTableViewCell.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/8/18.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "EditContentTableViewCell.h"

@implementation EditContentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    self.leftLab = [[UILabel alloc] init];
    self.leftLab.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.leftLab];
    
    self.contetField = [[UITextField alloc] init];
    
    self.contetField.textColor = [UIColor blackColor];
    self.contetField.font = [UIFont systemFontOfSize:14];
    self.contetField.textAlignment = NSTextAlignmentRight;
    self.contetField.returnKeyType = UIReturnKeyDone;
    
    [self.contentView addSubview:self.contetField];
    self.contetField.delegate = self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.leftLab.frame = CGRectMake(20, 0, kScreenWidth / 4, self.contentView.frame.size.height);
    self.contetField.frame = CGRectMake(self.leftLab.maxX + 5, 0, kScreenWidth - self.leftLab.maxX - 30, self.contentView.frame.size.height);
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    [self.editContentCellDelegate saveMessageWithValue:textField.text andKey:self.leftLab.text];
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
